package com.company.Lab1;

import java.util.Scanner;

public class    Echiprobilitatii {
    public static void main(String[] args) {
        int[][] echiprobArr;
        Scanner scanner = new Scanner(System.in);
        int r, c;

        System.out.println("Introducerti numarul de randuri : ");
        r = scanner.nextInt();
        System.out.println("Introduceti numarul de coloane : ");
        c = scanner.nextInt();

        echiprobArr = new int[r][c];
        float[] sum = new float[r];
        float coefficient = (float) 1 / c;
        float max, min;

        System.out.println("Introduceti datele matrcii :");

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                System.out.print("[" + i + "][" + j + "] : ");
                echiprobArr[i][j] = scanner.nextInt();
            }
        }
//        calcule
//        calculam suma pe rand
        for (int i = 0; i < r; i++) {
            sum[i] = 0;
            for (int j = 0; j < c; j++) {
                sum[i] = sum[i] + echiprobArr[i][j];
            }
            sum[i] = sum[i] * coefficient;
            System.out.println("Suma pentru randul " + i + " : " + sum[i]);
        }
//        Calc max
        max = sum[1];
        for (int i = 0; i < r; i++) {
            max = Math.max(max,sum[i]);
        }
        System.out.println("Valoarea expectanta finala este : " + max);
    }
}